//原型继承
function Father(sex) {
    this.sex = sex
}
Father.prototype.hello = 'hi'
function Son(name) {
    this.name = name
}
Son.prototype = new Father('man')

var xiaohong = new Son('xiaohong')
xiaohong.__proto__.sex = 'woman'
var xiaoming = new Son('xiaoming')
console.log(xiaoming.sex);
console.log(xiaoming.hello);
//构造器继承
function Father(sex) {
    this.sex = sex
}
Father.prototype.hello = 'hi'
function Son(name) {
    this.name = name
    Father.call(this, 'man')
}

var xiaohong = new Son('xiaohong')
xiaohong.__proto__.sex = 'woman'
var xiaoming = new Son('xiaoming')
console.log(xiaoming.sex);
console.log(xiaoming.hello);
//组合继承
function Father(sex) {
    this.sex = sex
}
Father.prototype.hello = 'hi'
function Son(name) {
    this.name = name
    Father.call(this, 'man')
}
Son.prototype = new Father('man')

var xiaohong = new Son('xiaohong')
xiaohong.__proto__.sex = 'woman'
var xiaoming = new Son('xiaoming')
console.log(xiaoming.sex);
console.log(xiaoming.hello);
//寄生组合继承
function Father(sex) {
    this.sex = sex
}
Father.prototype.hello = 'hi'
function Son(name) {
    this.name = name
    Father.call(this, 'man')
}
//Object.create方法传的值为 构造函数的原型，生成的对象为 该构造函数和该构造函数的原型
const obj = Object.create(Father.prototype)
Son.prototype = obj

var xiaohong = new Son('xiaohong')
xiaohong.__proto__.sex = 'woman'
var xiaoming = new Son('xiaoming')
console.log(xiaoming.sex);
console.log(xiaoming.hello);